package com.gson.inter;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.Scanner;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.methods.GetMethod;



public class chat {

	public static void main(String[] args) {
		while(true){
		Scanner hp=new Scanner(System.in);
		String chat=hp.next();
		String recontent=chatting(chat);
		System.err.println("对方说"+recontent);
		hp.reset();
		}
	}
	public static String chatting(String content){
		String eString=URLEncoder.encode(content);
		String u="http://xiaofengrobot.sinaapp.com/api.php?text="+eString;
		HttpClient client=new HttpClient();
		GetMethod get=new GetMethod(u);
		String str="";
		try {
			client.executeMethod(get);
			str=new String(get.getResponseBodyAsString().getBytes("iso-8859-1"),"utf-8");
		} catch (HttpException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return str;
	
	}
}
